<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>composition API-toRef reactive</title>
  <script src="https://unpkg.com/vue@next"></script>
</head>
<body>
  <div id="root"></div>
</body>
<script>
  // toRef 
  const app = Vue.createApp({
    template: `
      <div>age: {{age}}</div>
    `,
		setup(props,context) {
	
			const {reactive, toRefs,toRef} = Vue
			
			const userInfo = reactive({name:'dell'})
			// age不存在 用toRefs 响应式数据就会报错 这时候用toRef
			//const {age} = toRefs(userInfo)
			const age = toRef(userInfo,'age')
			setTimeout(()=>{
				age.value ='lee'
			},2000)

			return {
				age
			}
		}
  });
  const vm = app.mount('#root');
</script>
</html>